<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>表单验证1-检查6位数字</title>
    <script>
        function checkUserpsw(){
           upsw= document.getElementById("Userpsw").value;
           flag = true;
           for(i=0;i<upsw.length;i++){
               num = upsw.charAt(i);
               if(!(num >= 0 && num <= 9)){
                   flag = false;
                   break ;
               }
           }
            if(upsw.length != 6){
                flag=false;
            }
            console.log(flag);
           return flag;



        }
    </script>
</head>
<body>
<form action="js网页输出.html" method="post" onsubmit="return checkUserpsw()">
    <input type="text" id="Userpsw" value=""> <br>
    <input type="submit" value="注册">
</form>
</body>
</html>